import 'package:flutter/material.dart';

class RadioDemo extends StatefulWidget {
  RadioDemo({Key key}) : super(key: key);

  @override
  _RadioDemoState createState() => _RadioDemoState();
}

class _RadioDemoState extends State<RadioDemo> {
  int _radioGoupA = 0;
  int _radioGoupB = 0;

  void _handlerRadioValueChanged(value) {
    setState(() {
      _radioGoupA = value;
    });
  }

  void _handlerRadioValueChanged2(value) {
    setState(() {
      _radioGoupB = value;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("RadioDemo"),
        elevation: 0.0,
      ),
      body: Container(
        padding: EdgeInsets.all(16.0),
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text("RadioGroupValue: $_radioGoupB"),
            SizedBox(height: 32.0),
            RadioListTile(
              value: 0, 
              groupValue: _radioGoupB, 
              onChanged: _handlerRadioValueChanged2,
              title: Text("Radio Options 1"),
              subtitle: Text("Radio Description"),
              secondary: Icon(Icons.filter_1),
              selected: _radioGoupB == 0,
            ),
            RadioListTile(
              value: 1, 
              groupValue: _radioGoupB, 
              onChanged: _handlerRadioValueChanged2,
              title: Text("Radio Options 2"),
              subtitle: Text("Radio Description"),
              secondary: Icon(Icons.filter_2),
              selected: _radioGoupB == 1,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Radio(
                  value: 0,
                  groupValue: _radioGoupA,
                  onChanged: _handlerRadioValueChanged,
                  activeColor: Colors.black,
                ),
                Radio(
                  value: 1,
                  groupValue: _radioGoupA,
                  onChanged: _handlerRadioValueChanged,
                  activeColor: Colors.black,
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}